package hs.framework.opcClient.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @Description 同时传递操作成功的操作和操作失败的操作
 * @Author sxmz
 * @Date 2021/5/14 0014 下午 1:59
 */
@ApiModel(
        description = "操作结果集"
)
@Data
@AllArgsConstructor
public class ListResult<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(
            value = "成功操作",
            required = true
    )
    private List<T> successResult;

    @ApiModelProperty(
            value = "成功操作数量",
            required = true
    )
    private int successNumber;

    @ApiModelProperty(
            value = "失败操作",
            required = true
    )
    private List<T> failResult;

    @ApiModelProperty(
            value = "失败操作数量",
            required = true
    )
    private int failNumber;

    public static <T> ListResult<T> build(List<T> successResult,List<T> failResult){
        return new ListResult(successResult,successResult.size(),failResult,failResult.size());
    }
}
